<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta name="Content-Type" content="text/html; charset=UTF-8" />
<title>Class: Sass::CacheStores::Base</title>
<link rel="stylesheet" href="style.css" tppabs="http://sass-lang.com/docs/yardoc/css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="common.css" tppabs="http://sass-lang.com/docs/yardoc/css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '../..';
  if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="jquery.js" tppabs="http://sass-lang.com/docs/yardoc/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="app.js" tppabs="http://sass-lang.com/docs/yardoc/js/app.js"></script>

  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html" tppabs="http://sass-lang.com/docs/yardoc/_index.html">Index (B)</a> &raquo; 
    <span class='title'><a href="Sass-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass.html" title="Sass (module)">Sass</a></span> &raquo; <span class='title'><a href="CacheStores.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/CacheStores.html" title="Sass::CacheStores (module)">CacheStores</a></span>
     &raquo; 
    <span class="title">Base</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="javascript:if(confirm(%27http://sass-lang.com/docs/yardoc/Sass/CacheStores/.  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?%27))window.location=%27http://sass-lang.com/docs/yardoc/Sass/CacheStores/.%27" tppabs="http://sass-lang.com/docs/yardoc/Sass/CacheStores/." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  <a id="class_list_link" href="#">Class List</a>
  <a id="method_list_link" href="#">Method List</a>
  <a id ="file_list_link" href="#">File List</a>
</div>

      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: Sass::CacheStores::Base 
  <span class="abstract note title">Abstract</span>
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Sass::CacheStores::Base</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">/var/www/sass-pages/.sass/lib/sass/cache_stores/base.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p class="note abstract">
  <strong>This class is abstract.</strong> 
  
</p>
<p>An abstract base class for backends for the Sass cache. Any key-value store can act as such a backend; it just needs to implement the <tt><a href="#_store-instance_method" title="Sass::CacheStores::Base#_store (method)">#_store</a></tt> and <tt><a href="#_retrieve-instance_method" title="Sass::CacheStores::Base#_retrieve (method)">#_retrieve</a></tt> methods.</p>

<p>To use a cache store with Sass, use the <a href="file.SASS_REFERENCE.html#cache_store-option" tppabs="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#cache_store-option" title="&lt;code&gt;:cache_store&lt;/code&gt; option"><code>:cache_store</code> option</a>.</p>

  </div>
</div>
<div class="tags">
  
</div><div id="subclasses">
  <h2>Direct Known Subclasses</h2>
  <p class="children"><a href="Chain.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/CacheStores/Chain.html" title="Sass::CacheStores::Chain (class)">Chain</a>, <a href="Filesystem-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/CacheStores/Filesystem.html" title="Sass::CacheStores::Filesystem (class)">Filesystem</a>, <a href="Memory.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/CacheStores/Memory.html" title="Sass::CacheStores::Memory (class)">Memory</a></p>
</div>



  <h2>Instance Method Summary</h2>

  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#_retrieve-instance_method" title="#_retrieve (instance method)">- (String, NilClass) <strong>_retrieve</strong>(key, version, sha) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Retrieved cached contents.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#_store-instance_method" title="#_store (instance method)">- <strong>_store</strong>(key, version, sha, contents) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Store cached contents for later retrieval Must be implemented by all CacheStore subclasses.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#key-instance_method" title="#key (instance method)">- <strong>key</strong>(sass_dirname, sass_basename) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Return the key for the sass file.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#retrieve-instance_method" title="#retrieve (instance method)">- (Object) <strong>retrieve</strong>(key, sha) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Retrieve a <tt><a href="RootNode.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/RootNode.html" title="Sass::Tree::RootNode (class)">Sass::Tree::RootNode</a></tt>.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#store-instance_method" title="#store (instance method)">- <strong>store</strong>(key, sha, root) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Store a <tt><a href="RootNode.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/RootNode.html" title="Sass::Tree::RootNode (class)">Sass::Tree::RootNode</a></tt>.</span>
  
</li>

    
  </ul>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="_retrieve-instance_method">
  
    - (<tt>String</tt>, <tt>NilClass</tt>) <strong>_retrieve</strong>(key, version, sha) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Retrieved cached contents. Must be implemented by all subclasses.</p>

<p>Note: if the key exists but the sha or version have changed, then the key may be deleted by the cache store, if it wants to do so.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>key</span>
      
      
      
        &mdash;
        The key to retrieve
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>version</span>
      
      
      
        &mdash;
        The current sass version. Cached contents must not be retrieved across different versions of sass.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>sha</span>
      
      
      
        &mdash;
        The sha of the sass source. Cached contents must not be retrieved if the sha has changed.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
        &mdash;
        The contents that were previously stored.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>NilClass</tt>)</span>
      
      
      
      
        &mdash;
        when the cache key is not found or the version or sha have changed.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


41
42
43</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/cache_stores/base.rb', line 41</span>

def _retrieve(key, version, sha)
  raise "#{self.class} must implement #_retrieve."
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="_store-instance_method">
  
    - <strong>_store</strong>(key, version, sha, contents) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Store cached contents for later retrieval Must be implemented by all CacheStore subclasses</p>

<p>Note: cache contents contain binary data.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>key</span>
      
      
      
        &mdash;
        The key to store the contents under
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>version</span>
      
      
      
        &mdash;
        The current sass version. Cached contents must not be retrieved across different versions of sass.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>sha</span>
      
      
      
        &mdash;
        The sha of the sass source. Cached contents must not be retrieved if the sha has changed.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>contents</span>
      
      
      
        &mdash;
        The contents to store.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


24
25
26</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/cache_stores/base.rb', line 24</span>

def _store(key, version, sha, contents)
  raise "#{self.class} must implement #_store."
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="key-instance_method">
  
    - <strong>key</strong>(sass_dirname, sass_basename) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Return the key for the sass file.</p>

<p>The <code>(sass_dirname, sass_basename)</code> pair should uniquely identify the Sass document, but otherwise there are no restrictions on their content.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>sass_dirname</span>
      
      
      
        &mdash;
        The fully-expanded location of the Sass file. This corresponds to the directory name on a filesystem.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>sass_basename</span>
      
      
      
        &mdash;
        The name of the Sass file that is being referenced. This corresponds to the basename on a filesystem.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


79
80
81
82
83</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/cache_stores/base.rb', line 79</span>

def key(sass_dirname, sass_basename)
  dir = Digest::SHA1.hexdigest(sass_dirname)
  filename = "#{sass_basename}c"
  "#{dir}/#{filename}"
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="retrieve-instance_method">
  
    - (<tt>Object</tt>) <strong>retrieve</strong>(key, sha) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Retrieve a <tt><a href="RootNode.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/RootNode.html" title="Sass::Tree::RootNode (class)">Sass::Tree::RootNode</a></tt>.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>key</span>
      
      
      
        &mdash;
        The key the root element was stored under.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>sha</span>
      
      
      
        &mdash;
        The checksum of the root element&#8217;s content.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
      
      
        &mdash;
        The cached object.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


61
62
63
64
65
66</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/cache_stores/base.rb', line 61</span>

def retrieve(key, sha)
  contents = _retrieve(key, Sass::VERSION, sha)
  Marshal.load(contents) if contents
rescue EOFError, TypeError, ArgumentError, LoadError => e
  Sass::Util.sass_warn "Warning. Error encountered while reading cache #{path_to(key)}: #{e}"
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="store-instance_method">
  
    - <strong>store</strong>(key, sha, root) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Store a <tt><a href="RootNode.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Tree/RootNode.html" title="Sass::Tree::RootNode (class)">Sass::Tree::RootNode</a></tt>.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>key</span>
      
      
      
        &mdash;
        The key to store it under.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>sha</span>
      
      
      
        &mdash;
        The checksum for the contents that are being stored.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
        <span class='name'>obj</span>
      
      
      
        &mdash;
        The object to cache.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


50
51
52
53
54</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/cache_stores/base.rb', line 50</span>

def store(key, sha, root)
  _store(key, Sass::VERSION, sha, Marshal.dump(root))
rescue TypeError, LoadError => e
  Sass::Util.sass_warn "Warning. Error encountered while saving cache #{path_to(key)}: #{e}"
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Fri Mar  8 20:33:57 2013 by 
  <a href="javascript:if(confirm(%27http://yardoc.org/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?%27))window.location=%27http://yardoc.org/%27" tppabs="http://yardoc.org/" title="Yay! A Ruby Documentation Tool">yard</a>
  0.5.3 (ruby-1.8.7).
</div>


  <script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
  try {
  var pageTracker = _gat._getTracker("UA-535380-8");
  pageTracker._trackPageview();
  } catch(err) {}</script>


  </body>
</html>